package il.ac.biu.cs.grossmm.api.keys;

/**
 * Represents key pattern entry. A key pattern entry is a tuple containing an
 * attribute, pattern and a mandatory/optional flag.
 */
public final class PatternEntry {
	private final Attribute attribute;

	private final KeyPattern keyPattern;

	private final boolean isMandatory;

	/**
	 * Creates a new pattern entry.
	 * 
	 * @param attribute
	 *            pattern attribute
	 * @param keyPattern
	 *            the pattern
	 * @param isMandatory
	 *            true iff the pattern entry is mandatory
	 */
	public PatternEntry(Attribute attribute, KeyPattern keyPattern,
		boolean isMandatory)
	{
		assert (attribute != null);
		assert (keyPattern != null);

		this.attribute = attribute;
		this.keyPattern = keyPattern;
		this.isMandatory = isMandatory;
	}

	/**
	 * Gets the attribute associated with this pattern entry.
	 * 
	 * @return the attribute associated with this pattern entry
	 */
	public Attribute getAttribute()
	{
		return attribute;
	}

	/**
	 * Gets the pattern associated with this pattern entry.
	 * 
	 * @return the pattern associated with this pattern entry
	 */
	public KeyPattern getPattern()
	{
		return keyPattern;
	}

	/**
	 * Queries whether the pattern entry is mandatory
	 * 
	 * @return true if the pattern entry is mandatory, false otherwise
	 */
	public boolean isMandatory()
	{
		return isMandatory;
	}
}
